package com.ruoyi.project.mydy.expoinfo.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.mydy.expoinfo.domain.DlExpoInfo;
import com.ruoyi.project.mydy.expoinfo.service.IDlExpoInfoService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 展厅信息Controller
 * 
 * @author mhg
 * @date 2021-10-07
 */
@Controller
@RequestMapping("/mydy/expoinfo")
public class DlExpoInfoController extends BaseController
{
    private String prefix = "mydy/expoinfo";

    @Autowired
    private IDlExpoInfoService dlExpoInfoService;

    @RequiresPermissions("mydy:expoinfo:view")
    @GetMapping()
    public String expoinfo()
    {
        return prefix + "/expoinfo";
    }

    /**
     * 查询展厅信息列表
     */
    @RequiresPermissions("mydy:expoinfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DlExpoInfo dlExpoInfo)
    {
        startPage();
        List<DlExpoInfo> list = dlExpoInfoService.selectDlExpoInfoList(dlExpoInfo);
        return getDataTable(list);
    }

    /**
     * 导出展厅信息列表
     */
    @RequiresPermissions("mydy:expoinfo:export")
    @Log(title = "展厅信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DlExpoInfo dlExpoInfo)
    {
        List<DlExpoInfo> list = dlExpoInfoService.selectDlExpoInfoList(dlExpoInfo);
        ExcelUtil<DlExpoInfo> util = new ExcelUtil<DlExpoInfo>(DlExpoInfo.class);
        return util.exportExcel(list, "展厅信息数据");
    }

    /**
     * 新增展厅信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存展厅信息
     */
    @RequiresPermissions("mydy:expoinfo:add")
    @Log(title = "展厅信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DlExpoInfo dlExpoInfo)
    {
        return toAjax(dlExpoInfoService.insertDlExpoInfo(dlExpoInfo));
    }

    /**
     * 修改展厅信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        DlExpoInfo dlExpoInfo = dlExpoInfoService.selectDlExpoInfoById(id);
        mmap.put("dlExpoInfo", dlExpoInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存展厅信息
     */
    @RequiresPermissions("mydy:expoinfo:edit")
    @Log(title = "展厅信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DlExpoInfo dlExpoInfo)
    {
        return toAjax(dlExpoInfoService.updateDlExpoInfo(dlExpoInfo));
    }

    /**
     * 删除展厅信息
     */
    @RequiresPermissions("mydy:expoinfo:remove")
    @Log(title = "展厅信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(dlExpoInfoService.deleteDlExpoInfoByIds(ids));
    }
}
